from common.models.check_data import CheckData
import pandas as pd
from application import ExoskeletonEngine as engine
import os
import sys

from sqlalchemy import create_engine
import numpy as np
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import or_, and_
from sqlalchemy.sql import func
from datetime import date, timedelta
from pyecharts import options as opts
from pyecharts.charts import Map
from flask import Blueprint, request, redirect, url_for
engine = create_engine('mysql+pymysql://exoskeleton:116648728gG@192.168.153.206:3306/exoskeleton')

sql = ''' select * from bpm_data; '''
ordata = pd.read_sql_query(sql, engine)

date = "202111"
data = ordata[ordata["date"] == date].loc[:, ["company", "totalnum", "date"]]
data = data["totalnum"].groupby(data["company"]).sum().reset_index().replace(
    ["地产集团西北区域公司", "地产集团西北区域山西公司", "地产集团西北区域内蒙古公司", "地产集团西北区域陕西公司", "地产集团西北区域兰州公司", "地产集团西北区域乌鲁木齐公司"],
    ["区域", "山西", "内蒙古", "陕西", "兰州", "乌鲁木齐"])

x = data["company"].values.tolist()
y1 = data["totalnum"].values.tolist()
print(data)